<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,minimum-scale=1,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/base.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/font/font-awesome-4.7.0/css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/plug-in/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/third-company.css" />
    <script src="/public/static/wx/js/flex.js" type="text/javascript" charset="utf-8"></script>
    <title>派单</title>
</head>

<body>
<div class="index">
    <div class="topbar">
        <a href="javascript:history.go(-1);"><i class="fa fa-angle-left"></i></a>
        <p>选择区域经理</p>
    </div>
    <div class="content">
        <ul id="dataList">
            <li vid = "0" onclick="senid(this)">
            <p>自主接单</p><i class="fa fa-circle-o "></i>
            </li>
        </ul>
        <div class="btn" onclick="send()">确定</div>
    </div>
</div>
<script src="/public/static/wx/js/jquery-3.3.1.min.js " type="text/javascript " charset="utf-8 "></script>
<script src="/public/static/wx/plug-in/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript ">


    var vid = '';
    let load_index = layer.load(1,{shade:0.2,offset:['45%','45%']});
    $.post('{:url("engins")}',function (data) {
        layer.close(load_index);
        $.each(data.data,function (k,v) {
            var str = '<li vid = '+v.id+' onclick="senid(this)">\n' +
                '<p>'+v.value+'</p><i class="fa fa-circle-o "></i>\n' +
                '</li>';

            $('#dataList').append(str);
        });


        $('.content ul li').on('click',function(){

            $(this).siblings('li').removeClass('active').find('i').removeClass('fa-dot-circle-o').addClass('fa-circle-o');
            $(this).addClass('active').find('i').removeClass('fa-circle-o').addClass('fa-dot-circle-o');

        });

    });

    function senid(_t) {
        vid = $(_t).attr('vid');
    }
    var id = '{:input("id")}';
    function send() {
        if(vid.length<=0){
            layer.msg('请选择区域经理',{icon:5});
            return;
        }
        let load_index = layer.load(2,{shade:0.2,offset:['45%','45%']});
        $.post('{:url("disToEngin")}',{aid:vid,id:id},function (res) {
            layer.close(load_index);
            if(res.code==1){
                layer.msg(res.msg,{icon:6,shade:0.1},function () {
                    self.location=document.referrer;
                });
            }else{
                layer.msg(res.msg,{icon:5});
            }
        });
    }

</script>
</body>
</html>